﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HtmlAgilityPack;
using Odds.Entity;
using System.Text;
using Odds.Business;
using System.IO;
using Odds.DataAccess;

public partial class ResultCollection : System.Web.UI.Page
{
    string testUrl = "http://act2.sports.sohu.com/zucai/file/zucai-2009-asc.html";

    protected void Page_Load(object sender, EventArgs e)
    {
        txtUrl.Text = testUrl;
    }

    protected void btnUrl_Click(object sender, EventArgs e)
    {
        string str = txtUrl.Text;

        MatchResultOrganizeMonitor r = new MatchResultOrganizeMonitor(str);

        new OddsIssueItemController().IssueItemUpdate(r._OddsResultSet);
    }

    protected void btnFile_Click(object sender, EventArgs e)
    {
        string strResult = File.ReadAllText(Server.MapPath("../ResultFile/" + fuResult.FileName), Encoding.GetEncoding("gb2312"));

        MatchResultOrganizeMonitor r = new MatchResultOrganizeMonitor(strResult, 0);

        new OddsIssueItemController().IssueItemUpdate(r._OddsResultSet);
    }


    protected void btnSingleIssue_Click(object sender, EventArgs e)
    {
        string strIssueRealID = txtSingleIssue.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[0];
        string strResultList = txtSingleIssue.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)[1];

        OddsResult oddsResult = new OddsResult();

        oddsResult.OddsIssueRealID = int.Parse(strIssueRealID);
        oddsResult.OddsIssueItemMatchResult = strResultList.Replace("*", "4")
            .Replace("	",string.Empty).Replace("\t",string.Empty)
            .ToList().Select(r => short.Parse(r.ToString())).ToList();

        new OddsIssueItemController().IssueItemResultUpdate(oddsResult);

        lblSingleInfo.Text = "Result of issue " + strIssueRealID + " has import successful.";
    }
}
